import rowSchema from 'take-widgets/layout/row';
import colSchema from 'take-widgets/layout/col';
import buttonSchema from 'take-widgets/element/button';
import inputSchema from 'take-widgets/form/input';
import formSchema from 'take-widgets/form/form';
import dialogSchema from 'take-widgets/element/dialog';
import searchSchema from 'take-widgets/template/search-table';
// import * as filterTable from 'take-widgets/template/filter-table';
import Page from 'drag/widgets/page';

import { IWidgets } from 'drag/index.d';
import { IWidgets as IRenderWidgets } from 'schema-render/index.d';

const widgets = {
  ...rowSchema,
  ...buttonSchema,
  ...colSchema,
  ...inputSchema,
  ...formSchema,
  ...dialogSchema,
  ...searchSchema,
  // ...filterTable.filterTable,
  // ...filterTable.FilterTableWrapper,
  // ...filterTable.FilterTableFilterWrapper,
} as IWidgets;

function getRenderWidgets(): IRenderWidgets {
  let obj: IRenderWidgets = { page: Page };

  Object.keys(widgets).forEach((key) => {
    obj[key] = widgets[key].component;
  });

  return obj;
}

export default widgets;
export const renderWidgets = getRenderWidgets();
